// -----------------------------------------------------------------------
//  <copyright file="GetOrganizationPageQuery.cs" company="LiuliuSoft">
//      Copyright (c) 2022-2024 DaprPlus. All rights reserved.
//  </copyright>
//  <site>https://dapr.plus</site>
//  <last-editor>郭明锋</last-editor>
//  <last-date>2024/12/9 10:59:52</last-date>
// -----------------------------------------------------------------------

using DaprPlus.Identity.Domain.Entities;


namespace DaprPlus.Identity.Application.Identity.Organizations.Queries;

[AuthConfig(typeof(Organization), ResourceAccessType.RoleLimit, "GetPage")]
public class GetOrganizationPageQuery : PageQuery<PageResult<OrganizationOutDto>>
{ }

public class GetOrganizationPageQueryHandler(IQueryRepository<Organization> queryRepository)
    : IRequestHandler<GetOrganizationPageQuery, PageResult<OrganizationOutDto>>
{
    public async Task<PageResult<OrganizationOutDto>> Handle(GetOrganizationPageQuery request, CancellationToken cancellationToken)
    {
        var spec = new PageQuerySpecification<Organization>(request.PageCondition, request.FilterGroup);
        var page = await queryRepository.GetPageAsync<OrganizationOutDto>(spec, cancellationToken);
        return page;
    }
}

